﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using LibNiconico.NiconicoApi.Videos;
using LibNiconico.NiconicoApi.Utils;
using LibNiconico.NiconicoApi.Exceptions;

namespace LibNiconico.NiconicoApi.Internal.Http
{
    /// <summary>
    /// ログインを前提とするニコニコ情報取得API
    /// </summary>
    internal sealed class MostLoginNiconicoApiHttpClient:NiconicoApiHttpClient
    {



        private MostLoginNiconicoApiHttpClient() : base() { }

        private NiconicoAuth auth;


        protected override void BeforeRequest(Uri url)
        {

            this.CookieContainer.Add(url, auth.UserSession);
        }






        /// <summary>
        /// 生成情報をもとにAPIを作成
        /// </summary>
        /// <param name="createInfo"></param>
        /// <param name="auth"></param>
        /// <returns></returns>
        internal  static MostLoginNiconicoApiHttpClient Create(NiconicoAuth auth, NiconicoApiInfoGetCreateInfo createInfo)
        {
            if (auth == null || !auth.IsSetAuth) throw NicoApiException.CreateNotLoginException();
            MostLoginNiconicoApiHttpClient api = new MostLoginNiconicoApiHttpClient();
            api.auth = auth;
            return api;

        }


    }
}
